package cn.yilongquan.mapper;

import cn.yilongquan.user.domain.Article;
import cn.yilongquan.user.query.ArticleQuery;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.MapKey;

import java.util.List;
import java.util.Map;

public interface ArticleMapper {

    Article findById(Long id);

    List<Article> findAll();

    void deleteById(Long id);

    void batchDelete(List<Long> ids);

    void add(Article article);

    void update(Article article);

    List<Article> pageList(ArticleQuery articleQuery);


    // 查询同类型相关文章
    List<Article> findRelatedByType(@Param("articleType") Long articleType,
                                    @Param("currentId") Long currentId);

    // 新增：查询点赞数前六的文章
    List<Article> findTop6ByStarNum();

    @MapKey("tagName")
    List<Map<String, Object>> findTop5TagCount();

    void increaseReadCount(Long id);
    // 获取当前浏览量
    int getReadCountById(Long id);


    // 更新点赞数 +1
    int increaseStarNum(@Param("articleId") Long articleId);
    // 查询当前点赞数
    int getStarNum(@Param("articleId") Long articleId);
}